import NativeFrameUtil from '@/NativeFrameUtil';
import { UnitInfoConfigs } from '../Config';

export default class UnitInfoModel {
    config: UnitUIConfig;
    constructor() {
        this.hideNativeUI();
        this.initConfig();
    }
    initConfig() {
        this.config = UnitInfoConfigs;
        let i = 0;
        for (let item of this.config.status) {
            item.width = 0.058;
            item.height = 0.02;
            item.x = Math.floor(i / 4) * 0.06 + 0.013;
            item.y = 0.005 + Math.floor(i % 4) * -0.021;
            i++;
        }
        i = 0;
        for (let item of this.config.attributes) {
            item.width = 0.01;
            item.height = 0.015;
            item.x = -0.12;
            item.y = 0.06 + i * -0.016;
            i++;
        }
    }
    hideNativeUI() {
        let u = DzSimpleFrameFindByName('SimpleInfoPanelUnitDetail', 0);

        DzFrameClearAllPoints(u);
        DzFrameSetSize(u, 0.5, 0.4);
        DzFrameSetPoint(u, 4, DzGetGameUI(), 4, 0, -0.5);
        // 姓名
        let np = NativeFrameUtil.getUnitName();
        DzFrameClearAllPoints(np);
        DzFrameSetSize(np, 0.177, 0.014);
        DzFrameSetTextAlignment(np, TEXTALIGN_CENTER);
        DzFrameSetAbsolutePoint(np, FRAMEPOINT_TOPLEFT, 0.315, 0.12);
    }
}
